﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Koonsoft.Tool.CheckEveryday.Order.BLL
{
    public class TodayOrder
    {
        /// <summary>
        /// 获得当日订单数据
        /// </summary>
        /// <returns></returns>
        public TodayOrderInfo GetTodayOrder()
        {
            Koonsoft.Tool.CheckEveryday.Order.DAL.TodayOrder dal = new Koonsoft.Tool.CheckEveryday.Order.DAL.TodayOrder();

            return dal.GetTodayOrder();
        }

        /// <summary>
        /// 生成发送短信的报告
        /// </summary>
        /// <remarks>
        /// 因为短信字符不能超过70个，故对无用的数据不予以发送
        /// </remarks>
        /// <returns></returns>
        public string GetReport()
        {
            TodayOrderInfo orderinfo = GetTodayOrder();

            StringBuilder report = new StringBuilder();
            if(orderinfo.TotalOrders > 0)
            { 
                report.Append(string.Format("今日共有{0}订单，",orderinfo.TotalOrders));
            }
            if (orderinfo.FinishedOrders > 0)
            {
                report.Append(string.Format("完成{0}，", orderinfo.FinishedOrders));
            }
            if (orderinfo.ExceptionOrders > 0)
            { 
                report.Append(string.Format("异常{0}，",orderinfo.ExceptionOrders));                    
            }

            return report.ToString();
        }
    }
}
